var IMconn = null ;
var homeis = true;
var GuangGaoSta = true;
var jc_goods_listClass = 1;
var share_desc = '',share_title = '',share_img = '';
//_RT = null;

	//首页
	var home = {
		pageShow: function() {
			bindFunction();
			$(".footer0").show();
			if(homeis){
				homeis = false;
				pageFun.homegetdata();
			} 
			pageFun.home();
			$(".footer0 li:first-child").addClass('cur');
		},
		pageBeforeShow:function(){
			$('.indexShop_content').empty();
			pageFun.homegetdata();
			var ace = fun.getCache("ace");
		}
	};
	
	//附近麻将机店-五期
	var tpl_nearByMj = {
		pageShow:function(){
			bindFunction();
		},
		pageBeforeShow:function(){
			$('.tpl_nearByMj_main ul').empty();
			pageFun.nearByMj();
		}
	};
	
	//共享麻将机首页-五期
	var tpl_ShareMj = {
		pageShow:function(){
			bindFunction();
			pageFun.ShareMjFn();
		},
		pageBeforeShow:function(){
//			$(".ShareMj_navC1").empty();
			pageFun.ShareMjData();
		}
	};
	
	//共享麻将机详情页面-五期
	var tpl_ShareMj_Detail = {
		pageShow:function(){
			bindFunction();
			pageFun.ShareMj_Detail_Fn();
		},
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			pageFun.ShareMj_Detail_data(parm);
		}
	};
	
	//会员号主页面-五期
	var tpl_MemberNum = {
		pageShow:function(){
			bindFunction();
			pageFun.tpl_MemberNum();
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_MemberNumdata();
		}
	};
	//往期冠军展示-五期
	var tpl_Champion = {
		pageShow:function(){
			bindFunction();
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_Championdata();
		}
	};
	
	//个人中心-我的会员-五期
	var tpl_MyMember = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_MyMember();
		}
	};
	//个人中心-区/县管理-五期
	tpl_CountyManage = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_CountyManage();
		}
	};
	//往季销售额-五期
	tpl_WJSale = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_WJSale();
		}
	};
	//个人中心-排行榜-五期
	var tpl_rankPage = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_rankPage();
		}
	};
	//申请提现-五期
	var tpl_ApplyTX = {
		pageShow:function(){
			bindFunction();
			pageFun.tpl_ApplyTX();
		},
		pageBeforeShow:function(){ 
			pageFun.ApplyTXData();
		}
	};
	//提现记录-五期
	var tpl_TXRecord = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_TXRecord();
		}
	};
	//提现成功-五期
	var tpl_TXSuccess = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_TXSuccess();
		}
	};
	//查看物流-五期
	tpl_wuliuDetail = {
		pageShow:function(){
			bindFunction();
			pageFun.wuliuDetailFn();
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_wuliuDetail();
		}
	}
	//麻将配籽-五期
	tpl_shopPart = {
		pageShow:function(){
			bindFunction();
			$(".footer0").show();
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_shopPart();
		}
	}
	//申请退款-五期
	tpl_orderRefund = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.orderRefundData();
		}
	}
	//同意退款-五期
	tpl_agreeRefund = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_agreeRefund();
		}
	};
	//退款详情-五期
	tpl_refundDetail = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_refundDetail();
		}
	}
	//佣金明细
	tpl_Commission = {
		pageShow:function(){
			bindFunction();	
		},
		pageBeforeShow:function(){ 
			pageFun.tpl_Commission();
		}
	}
	
	// tpl_viprecharge  vip 充值
	var tpl_viprecharge = {
		pageShow: function() {
			bindFunction();
			pageFun.viprecharge();
		},
		pageBeforeShow:function(){
			Api.post(Api.jc_cz_center,{},function(obj){
				if(obj.s){
					$('.VipRecharge .myinfo p span').eq(0).text(obj.user.nickname);
					$('.VipRecharge .myinfo i').css('background-image','url('+obj.user.img+')');
					var html = '';
					$.each(obj.chongzhi,function(i,d){
						html += '<li type="'+d.order_type+'">'
						html += '	<span>'+d.title+'</span>'
						html += '	<span><span>￥</span>'+d.price+'</span>'
						html += '	<span>'+d.type+'</span>'
						html += '</li>';
					});
					$('.choiceblock').html(html);
					$('.choiceblock li').eq(0).addClass('Choice');
					var jiagea=$('.choiceblock>li:nth-child(1)>span:nth-child(2)').text();
					$('.postbtnbox .left span:nth-child(2)').html(jiagea);
				}
			});
		}
	};
	// 采集中心
	var tpl_collection = {
		pageShow: function() {
			bindFunction();
			pageFun.collection();
		},
		pageBeforeShow:function(){
			Api.post(Api.jc_center,{},function(obj){
				if(obj.s){
					// 轮播图
					var slideractive = '';
					var sliderhtml = '';
					sliderhtml += 	'<div id="collection_slider" class="mui-slider"><div class="mui-slider-group mui-slider-loop"><div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+obj.slider[obj.slider.length - 1].img+'"></a></div>';
					$.each(obj.slider,function(i,d){
						sliderhtml += '<div class="mui-slider-item"><a href="#"><img src="'+d.img+'"></a></div>';
						slideractive += '<div class="mui-indicator"></div>';
					});
					sliderhtml += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+obj.slider[0].img+'"></a></div>';
					sliderhtml += '</div><div class="mui-slider-indicator">';
					sliderhtml += slideractive;
					sliderhtml += '</div></div>';
					$('#CJZX .sliderbox').html(sliderhtml);
					$('#collection_slider .mui-slider-indicator .mui-indicator').eq(0).addClass('mui-active');
					
					var slider = mui("#collection_slider");
					slider.slider({
						interval: 3000
					});
					// 公告
					$('#CJZX .str5').text(obj.notice?obj.notice:'暂无公告！');
					
					// category  分类
					var categoryhtml = '';
					categoryhtml += '<ul>';
					$.each(obj.category,function(i,d){
						categoryhtml += '<li style="background-image: url('+d.img+');" type='+d.is_manage+' t_id='+d.id+' t_title='+d.title+'></li>';//<span>'+d.title+'</span>
					});
					categoryhtml += '</ul>';
					$('#collectionlistbox').html(categoryhtml);
					
				}
			});
		}
	}
	//管理中心-麻将机店铺-六期
	tpl_Administration2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Administration2();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationBefore2();
		}
	};
	
	// 管理中心
	var tpl_Administration = {
		pageShow: function() {
			bindFunction();
			pageFun.Administration();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationBefore();
		}
	}
	
	//客户管理  员工管理 年月表单-麻将机店铺-六期
	var tpl_CustomerList2 = {
		pageShow: function() {
			bindFunction();
			pageFun.CustomerList2();
		},
		pageBeforeShow:function(){
			pageFun.CustomerListBefore2();
		}
	}
	
	// 客户管理  员工管理 年月表单
	var tpl_CustomerList = {
		pageShow: function() {
			bindFunction();
			pageFun.CustomerList();
		},
		pageBeforeShow:function(){
			console.log('2222');
			pageFun.CustomerListBefore();
		}
	}
	// 采集中心 2级页面
	var tpl_collection2 = {
		pageShow: function() {
			bindFunction();
			pageFun.collection2();
		},
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			$('.collectionhead2').text(parm[0]);
			Api.post(Api.jc_goods_list,{category_id:parm[1],},function(obj){
				if(obj.s){
					$('#CollectionSubpage .headimg img').attr('src',obj.slider[0]);
					var pageClass = '';
					$.each(obj.category_list,function(i,d){
						pageClass += '<li tid='+d.id+'>'+d.title+'</li>';
					});
					$('.ClassList').html(pageClass);
					$('.ClassList li').eq(0).addClass('classSta');
				
					
					$('#CollectionSubpage .str5').text(obj.notice?obj.notice:'暂无公告！');
					var ListHtml = '';
					$.each(obj.goods_list, function(i,d) {
						ListHtml += '<li t_id="'+d.id+'">';
						ListHtml += 	'<i style="background-image: url('+d.img+');"></i>';
						ListHtml += 	'<p>'+d.goods_name+'</p>';
						ListHtml += 	'<p>';
						ListHtml += 		'<span>￥<span>'+d.price+'</span></span>';
						ListHtml += 		'<span>销量：<span>'+d.sales_num+'</span></span>';
						ListHtml += 	'</p>';
						ListHtml += '</li>';
					});
					$('#CollectionSubpage .goods ul').html(ListHtml);
				}
			});
		}
	}
	// 采集中心 商品详情
	var tpl_CollectionDetails ={
		pageShow: function() {
			bindFunction();
			pageFun.CollectionDetails();
		},
		pageBeforeShow:function(){
			pageFun.CollectionDetailsBefore();
		},
		pageBack:function(){
			$('.Shop_Scroll .DetailsSliderBox').html('');// 清理轮播图
			$('.CollectionDetails .Details-img .Img-Content pre').html(''); // 清理详情
		}
	}
	// 采集 购物车
	var tpl_CollectionCar = {
		pageShow: function() {
			bindFunction();
			pageFun.CollectionCar();
		},
		pageBeforeShow:function(){
			pageFun.CollectionCarBefore();
			
		}
	}
	// 采集支付
	var tpl_Payment = {
		pageShow: function() {
			bindFunction();
			pageFun.Payment();
		},
		pageBeforeShow:function(){
			pageFun.PaymentBefore();
			pageFun.UpVoucherBefore();
		}
	}
	// 客服
	var tpl_CustomerService = {
		pageShow: function() {
			bindFunction();
		},
		pageBeforeShow:function(){
			Api.post(Api.jc_service,{},function(obj){
				if(obj.s){
					var html = '';
					$.each(obj.lsit, function(i,d) {
						html += '<li tel="'+d.phone+'">';
						html += 	'<span class="check"></span>';
						html += 	'<i style="background-image:url('+d.img+')"></i>';
						html += 	'<span class="text">'+d.name+'</span>';
						html += '</li>';
					});
					$('.CustomerService .listbox').html(html);
					$('.CustomerService .listbox li').unbind('tap').on('tap',function(){
						$('.CustomerService .listbox li .check').removeClass('check2');
						$(this).find('.check').addClass('check2');
						var tel = $(this).attr('tel');
						$('.CustomerService .telphone').attr('href','tel:'+tel);
					});
				}
			})
		}
	}
	// 采集 上传凭条
	var tpl_UpVoucher = {
		pageShow: function() {
			bindFunction();
			pageFun.UpVoucher();
		},
		pageBeforeShow:function(){
			pageFun.UpVoucherBefore();
		}
	}
	// 采集 添加地址
	var tpl_NewAddAddress = {
		pageShow: function() {
			bindFunction();
			pageFun.NewAddAddress();
		},
		pageBeforeShow:function(){
//			pageFun.UpVoucherBefore();
		}
	}
	// 上传凭证 选择地址
	var tpl_UpVoucherAddresslist = {
		pageShow: function() {
			bindFunction();
			pageFun.UpVoucherAddresslist();
		},
		pageBeforeShow:function(){
			
		}
	}
	// 采集 管理中心 表单-六期
	var tpl_AdministrationForm2 = {
		pageShow: function() {
			bindFunction();
			pageFun.AdministrationForm2();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationFormBefore2();
		}
	}
	// 采集 表单详情-六期
	var tpl_AdministrationFormDetails2 = {
		pageShow: function() {
			bindFunction();
			pageFun.AdministrationFormDetails2();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationFormDetailsBefore2();
		}
	}
	
	// 采集 管理中心 表单
	var tpl_AdministrationForm = {
		pageShow: function() {
			bindFunction();
			pageFun.AdministrationForm();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationFormBefore();
		}
	}
	// 采集 表单详情
	var tpl_AdministrationFormDetails = {
		pageShow: function() {
			bindFunction();
			pageFun.AdministrationFormDetails();
		},
		pageBeforeShow:function(){
			pageFun.AdministrationFormDetailsBefore();
		}
	}
	
	// 采集订单
	var tpl_collectionorder = {
		pageShow: function() {
			bindFunction();
			pageFun.collectionorder();
		},
		pageBeforeShow:function(){
			pageFun.collectionorderBefore();
		}
	}
	// 物流详情
	var tpl_Logistics = {
		pageShow: function() {
			bindFunction();
			pageFun.Logistics();
		},
		pageBeforeShow:function(){
			pageFun.LogisticsBefore();
		}
	}
	
	// 签到页面
	var tpl_SignPage = {
		pageShow: function() {
			bindFunction();
			$('.SignProductBox ul li').unbind('tap').on('tap',function(){
				var type = $(this).attr('type');
				viewApi.go('#tpl_ProductPage',type);
			});
		},
		pageBeforeShow:function(){
			Api.post(Api.sign_in_prizes,{},function(obj){
				var goods = obj.d.goods_list;
				var html = '';
				$.each(goods,function(i,d){
					html += '<li type="'+d.id+'"> <div class="SignProduct_img" style="background-image:url('+d.list_img+')"></div> <p class="SignProduct_p">'+d.title+'</p> <p class="SignProduct_text">签到'+d.sign_in_num+'次就是你的了</p> </li>';
				});
				$(".SignProductBox ul").html(html);
				
				var UserName = obj.d.record;
				var UserNameHtml = '';
				
				UserNameHtml += '<div class="PriceList_mask"></div><div class="swiper-container" id="PriceList_swiper"><div class="swiper-wrapper">';
				UserNameHtml += '<div class="swiper-slide"><p>恭喜用户名为'+UserName[0].nickname+'获得'+UserName[0].title+'！</p><p>恭喜用户名为'+UserName[1].nickname+'获得'+UserName[1].title+'！</p><p>恭喜用户名为'+UserName[2].nickname+'获得'+UserName[2].title+'！</p></div>';
				UserNameHtml += '<div class="swiper-slide"><p>恭喜用户名为'+UserName[3].nickname+'获得'+UserName[3].title+'！</p><p>恭喜用户名为'+UserName[4].nickname+'获得'+UserName[4].title+'！</p><p>恭喜用户名为'+UserName[5].nickname+'获得'+UserName[5].title+'！</p></div>';
				UserNameHtml += '<div class="swiper-slide"><p>恭喜用户名为'+UserName[6].nickname+'获得'+UserName[6].title+'！</p><p>恭喜用户名为'+UserName[7].nickname+'获得'+UserName[7].title+'！</p><p>恭喜用户名为'+UserName[8].nickname+'获得'+UserName[8].title+'！</p></div>';
				$('.SignPageMain .PriceList').html(UserNameHtml);
				var swiper222 = new Swiper('#PriceList_swiper', {
			        paginationClickable: true,
			        autoplay:2000,
			        autoplayDisableOnInteraction : false,
			        direction: 'vertical',
			        loop:true
			    });
			});
		}
	};
	
	// 签到完成
	var tpl_SignSuccess = {
		pageShow: function(){
			bindFunction();
		},
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			Api.post(Api.award_page,{id:parm[0]},function(obj){
				if(obj.s){
					$('.SignSuccess .SignImgBox b').css('background-image','url('+obj.d.img+')');
					if(obj.d.status == 1){
						$('.InputBox .ExpressBlock').hide();
						$('.InputBox .InputBlock').show();
					}else{
						$('.kuaidi').val(obj.d.express);
						$('.danhao').val(obj.d.express_number);
						$('.InputBox .ExpressBlock').show();
						$('.InputBox .InputBlock').hide();
					}
				}
			});
			
			$('.InputBlock button').unbind('tap').on('tap',function(){
				var name = $('.name').val();
				var phone = $('.phone').val();
				var address = $('.address').val();
				var te = /^1[3|4|5|8][0-9]\d{4,8}$/;
				if(name && phone && address){					
					if(te.test(phone)){
						Api.post(Api.award_address,{id:parm[0],user_name:name,mobile:phone,address:address},function(obj){
							if(obj.s){
								$('.InputBox .ExpressBlock').show();
								$('.InputBox .InputBlock').hide();
								$('.ExpressBlock').find('.kuaidi,.danhao').val('暂无数据');
								mui.toast('提交成功，请等待发货');
							}
						});					
					}else{
						mui.toast('请输入正确的手机号');
					}
				}else{
					mui.toast('请输入完整信息');
				}
			});
			
		}
	};
	
	// 签到成功
	var tpl_ProductPage2 = {
		pageBeforeShow:function(){
			var hhh = $(window).height() - $('.ProductImg').height() - $('.ProductName').height() - $('.ProductFooter').height() - $('.header_1').height() - 38;
			$('.ProductDetail').height(hhh);
			$('.ProductDetail pre.Content').height(hhh - 55);
			var parm = viewApi.parms;
			$(".ProductPageMain2 .signInShare_mask").show();
			Api.post(Api.sign_in_page,{id:parm[0]},function(obj){
				if(obj.s){
					//签到成功的分享
					var uurl = 'http://www.yuzhuli.com/Share/signInSuccess.html';
					share_desc = obj.d.info.share_desc;
					share_title = obj.d.info.share_title;
					share_img = obj.d.info.list_img;
					$('.ProductPageHead2 h2').text(obj.d.info.title);
					//蒙层的签到
					
					//下面按钮的分享
					pageFun.tpl_ProductPage2(share_title,share_desc,share_img,parm);					
					var log = obj.d.log;
					var dom =  $('.ProductPageMain2');
					$(dom).find('pre.Content').html(obj.d.info.content);
					$(dom).find('.ProductName').attr('type',obj.d.info.id);
					$(dom).find('.ProductName p').eq(0).text(obj.d.info.title);
					$(dom).find('.ProductName p').eq(1).text('签到'+obj.d.info.sign_in_num+'次就是你的了');
					$(dom).find('.ProductName span').text('已签到'+obj.d.num+'次');
					var html = '';
					$.each(log,function(i,d){
						html += '<li><i class="img" style="background-image:url('+d.img+')"></i><span class="txt">'+d.nickname+'</span><span class="time">'+d.time+'</span></li>';
					});
					$('.ProductPageMain2 .UserList').html(html);
					
					if(obj.d.lingqv == 1){
						$('.ProductPageMain2 .SignBtn').addClass('buttonSta');
						duihuan();
					}else{
						$('.ProductPageMain2 .SignBtn').removeClass('buttonSta');
					}
				}
			});
			$(".signInShare_btn2").unbind('tap').bind('tap',function(){
				$(".ProductPageMain2 .signInShare_mask").hide();
			})
			function duihuan(){
				$('.ProductPageMain2 .buttonSta').unbind('tap').on('tap',function(){
					var id = $(this).parent().attr('type');
					viewApi.go('#tpl_SignSuccess',id);
				});
			}
		},
		pageShow: function() {
			bindFunction(); 
		}
	}
	
	// 签到产品详情
	var tpl_ProductPage = {
		pageShow: function() {
			bindFunction();
//			$('.SignBtn2').unbind('tap').on("tap",function(){
//				var id = $(this).parent().attr('type');
//				var user_id = $(this).parent().attr('userid');
//				Api.post(Api.prizes_sign_in,{type:1,id:id},function(obj){
//						mui.toast(obj.m);
//						if(obj.s){
//							$("#tpl_ProductPage .ProductPageMain .signInShare_mask").show();
////							viewApi.go('#tpl_ProductPage2',[id,true,user_id]);
//						}else{
//							$("#tpl_ProductPage .ProductPageMain .signInShare_mask").show();
////							viewApi.go('#tpl_ProductPage2',[id,false,user_id]);
//						}					
//				});
//			});
			var hh = $(window).height() - $('.ProductPageMain .ProductName').height() - $('.ProductPageMain .ProductImg').height() - $('.ProductPageHead').height();			
			$('.ProductPageMain').find('.ProductDetail').height( hh - 27 );
			$('.ProductPageMain').find('.Content').height( hh - $('.ProductDetailTitle').height() - 35 );			
		},
		pageBeforeShow:function(){
			var parm = viewApi.parms[0];			
			Api.post(Api.prizes_detail,{id:parm},function(obj){
				if(obj.s){
					$("#tpl_ProductPage .read-box span").html(obj.d.info.views);
					$("#tpl_ProductPage .zan-box span").html(obj.d.info.like_num);
					$("#tpl_ProductPage .zan-box").attr('id',obj.d.info.id);
					$("#tpl_ProductPage .signInNum").html("已签到"+obj.d.num+"次");
					if(obj.d.info.is_sign_in){
						$("#tpl_ProductPage .SignBtn2").show();
						$("#tpl_ProductPage .signInNum").hide();
					}else{
						$("#tpl_ProductPage .SignBtn2").hide();
						$("#tpl_ProductPage .signInNum").show();
					}
					$('#tpl_ProductPage .zan-box').unbind('tap').bind('tap',function(){
						var id = $(this).attr('id');
						Api.post2(Api.prizes_like,{id:id},function(res){
							if(res.s){
								var num = Number(obj.d.info.like_num) + 1;
								$("#tpl_ProductPage .zan-box span").html(num);
							}else{
								if(res.m=="Token does not exist,Please login"){
									mui.toast("请登录");
								}
							}
						})
					})
					if(obj.d.ad){
						$('.ProductFooter img').attr({'src':obj.d.ad.img,'link':obj.d.ad.link});
					}else{
						$('.ProductFooter').hide();
					}
					$('.SignBtn2').unbind('tap').on("tap",function(){
						var id = $(this).parent().attr('type');
						var user_id = $(this).parent().attr('userid');
						if(obj.d.info.is_sign_in){
							//等于1的时候代表可以签到
							$("#tpl_ProductPage .ProductPageMain .signInShare_mask").show();
						}else{
							mui.toast("今日已签到");
							$("#tpl_ProductPage .ProductPageMain .signInShare_mask").hide();
						}
					});
					
					var share_desc = obj.d.info.share_desc;
					var share_title = obj.d.info.share_title;
					var share_img = obj.d.info.list_img;
					var parmArr = [parm,obj.d.user_id];
					pageFun.tpl_ProductPage4(share_title,share_desc,share_img,parmArr);
					
					
					$('.ProductPageHead h2').text(obj.d.info.title);
					$('.ProductImg i.Img').css('background-image','url('+obj.d.info.img+')');						
					$('pre.Content').html(obj.d.info.content);
					$('.ProductName').attr('type',obj.d.info.id);
					$('.ProductName').attr('userid',obj.d.user_id);					
					$('.ProductName p').eq(0).text(obj.d.info.title)
					$('.ProductName p').eq(1).text('签到'+obj.d.info.sign_in_num+'次就是你的了');
				}
				
			});
			var hhh = $(window).height() - $('.ProductImg').height() - $('.ProductName').height() - $('.ProductFooter').height() - $('.header_1').height() - 38;
			$('.ProductDetail').height(hhh);
			
			$('.ProductDetail pre.Content').height(hhh - 55)
		}
	};
	
	// 首页轮播详情
	var tpl_HomeBannerDetails = { 
		pageShow: function() {
			bindFunction(); 
			pageFun.tpl_HomeBannerDetails();
		},
		pageBeforeShow:function(){
			$('.HomeBannerDetailsHead h2').text('');
			$('.HomeBannerDetails').html('<pre class="HomeBannerDetailsBox"></pre>');
		}
	};
	
	// 品牌列表
	var tpl_MoreBrands = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_MoreBrands();
		}
	};
	
	// 头条列表
	var tpl_NewsList = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_NewsList();
		}
	};
	
	// 直播
	var tpl_BeautyLive = {
		pageBeforeShow:function(){
			setTimeout(function(){
				pageFun.tpl_BeautyLive();				
			},300);
		},
		pageShow: function() {
			bindFunction();
			$(".footer0").show();

		}
	};
	// 免费打牌
	var tpl_Admission = {
		pageBeforeShow:function(){
			$(".S_M_M_header.YuYue_uptab").css('top',$('.BrandHed').height()+$(".BrandPosition").height()+11);
			$(".BrandPosition").css("top",$(".BrandHed").height());
			$(".BrandMain").css('cssText','padding-top:2.18rem !important');
		},
		pageShow: function() {
			bindFunction();
//			$(".footer0").show();
			pageFun.tpl_Admission();
		}
	};
	// 品牌详情
	var tpl_DealerStore2 = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_DealerStore2();
			$('.Product pre').empty();
			$('#DealerStore .mui-slider-group').empty();
			var parm = viewApi.parms;
			Api.post(Api.brand_detail,{id:parm[0]},function(obj){
				if(obj.s){
					if(obj.ad){
						$("#tpl_DealerStore2 .footer-banner").show();
						$("#tpl_DealerStore2 .footer-banner-text p").eq(0).html(obj.ad.title);
						$("#tpl_DealerStore2 .footer-banner-text p").eq(1).html(obj.ad.desc);
						$("#tpl_DealerStore2 .I_Content_banner2").attr('src',obj.ad.img);
						$("#tpl_DealerStore2 .footer-banner-box").attr('d_url',obj.ad.url);
						$("#tpl_DealerStore2 .footer-banner-box").unbind('tap').bind('tap',function(){
							var weburl = fun.base64encode($(this).attr('d_url'));
							viewApi.go('#tpl_webview', weburl);
						})
					}else{
						$("#tpl_DealerStore2 .footer-banner").hide();
					}
					$("#tpl_DealerStore2 .read-box span").html(obj.d.views);
					
					$('.ProductName p').html(obj.d.product_name + '<span class="iconfont icon-zan">点赞'+obj.d.thumbs_up+'</span>');
					$('.Product pre').html(obj.d.content);
					$(".DealerStore2 a.phone").attr('href','tel:'+obj.d.hotline);
					$('#DealerStore2Head h2').text(obj.d.brand_name);
					var html = '';
					var html2 = '';
					$.each(obj.d.imgs,function(i,d){
						html += '<div class="mui-slider-item"><img src="'+d+'"></div>';
					});
					var num = obj.d.imgs.length;
					for(var e = 1;e <= num;e++){
						html2 += '<div class="mui-indicator"></div>';
					};
					$('.mui-slider-group').html(html);
					$('.mui-slider-indicator').html(html2);
					$('.mui-slider-indicator .mui-indicator').eq(0).addClass('mui-active');
					share(obj.d.product_name,obj.d.brand_desc,obj.d.logo,obj.d.id)
					czan();
				}else{
					mui.toast(obj.m);
				}
			});
			
			function share(product_name,brand_desc,logo,id){
				var uurl = 'http://www.yuzhuli.com/Share/DealerStore.html';
	    		pageFun.tpl_ProductPage3(product_name,brand_desc,logo,id,uurl,'.DealerStoreShare');
			}
			function czan(){
				$('.ProductName .icon-zan').unbind('tap').on('tap',function(){
					Api.post(Api.thumbs_up,{id:parm[0]},function(obj){
						if(obj.s){
							$('.ProductName .icon-zan').text("点赞" + obj.d.thumbs_up);
							mui.toast(obj.m);
						}else{
							if(obj.m == 'Token does not exist,Please login'){
								mui.toast('请先登录');
							}else{
								mui.toast(obj.m);								
							}
						}
					})
				});
			}
		},
		pageBeforeShow:function(){
		}
	}
	
	// 经销商店铺
	var tpl_DealerStore = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_DealerStore();
		}
	}
	
	//
	var tpl_nearby_shop_goods = {
		pageBeforeShow:function(){
			var parm = viewApi.parms;
			Api.post(Api.nearby_shop_goods,{id:parm[1]},function(obj){
				if(obj.s){
					//广告部分
					if(obj.ad){
						$("#tpl_nearby_shop_goods .footer-banner").show();
						$("#tpl_nearby_shop_goods .footer-banner-text p").eq(0).html(obj.ad.title);
						$("#tpl_nearby_shop_goods .footer-banner-text p").eq(1).html(obj.ad.desc);
						$("#tpl_nearby_shop_goods .I_Content_banner2").attr('src',obj.ad.img);
						$("#tpl_nearby_shop_goods .footer-banner-box").attr('d_url',obj.ad.url);
						$("#tpl_nearby_shop_goods .footer-banner-box").unbind('tap').bind('tap',function(){
							var weburl = fun.base64encode($(this).attr('d_url'));
							viewApi.go('#tpl_webview', weburl);
						})
					}else{
						$("#tpl_nearby_shop_goods .footer-banner").hide();
					}
					//点赞部分
					$("#tpl_nearby_shop_goods .read-box span").html(obj.d.views);
					$("#tpl_nearby_shop_goods .zan-box span").html(obj.d.like_num);
					$("#tpl_nearby_shop_goods .zan-box").attr('id',obj.d.nearby_shop_id);
					$('#tpl_nearby_shop_goods .zan-box').unbind('tap').bind('tap',function(){
						var id = $(this).attr('id');
						Api.post2(Api.nearby_shop_goods_like,{id:id},function(res){
							if(res.s){
								var num = Number(obj.d.like_num) + 1;
								$("#tpl_nearby_shop_goods .zan-box span").html(num);
							}else{
								if(res.m=="Token does not exist,Please login"){
									mui.toast("请登录");
								}
							}
						})
					})
					$('main.nearby_shop_goods pre').html(obj.d.content);
					$('.left img').attr('src',obj.d.wechat_pay_qr);
					$('.right img').attr('src',obj.d.alipay_qr);
					$('#nearby_shop_goodsBtn2').attr({'href':'tel:'+obj.mobile,'type':obj.mobile});
				}else{
					mui.toast(obj.m);
				}
			});
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_nearby_shop_goods();
		}
	}
	
	var tpl_PopApply = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_PopApply();
		}
	}
	
	//棋牌室列表
	var brand = {
		pageBeforeShow:function(){
			$(".S_M_M_header.YuYue_uptab").css('top',$('#brandHeader').height()+$("#brandMainPosition").height()+11);
			$("#brandMainPosition").css("top",$("#brandHeader").height());
			$("#brandMain").css('cssText','padding-top:2.18rem !important');
		},
		pageShow: function() {
			bindFunction();
			pageFun.brand();  
		}
	};
	//麻将馆详情
	var tpl_shop = {
		pageShow: function() {
			bindFunction();
			pageFun.shop();
			$('.mui-dtpicker').remove();
		},
		pageBeforeBack:function(){
			$('.mui-dtpicker').remove();
		}
	};
	/*
	 * 麻将馆活动编辑页面-六期
	 */
	var tpl_ShopEdit = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_ShopEdit();
		}
	};
	// 维修详情
	var tpl_RepairListInfo = {
		pageShow: function() {
			bindFunction();
			pageFun.tpl_RepairListInfo();
			$('.mui-dtpicker').remove();
		},
		pageBeforeBack:function(){
			$('.mui-dtpicker').remove();
		}
	};
	//资讯
	var tpl_information = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.information();  
		},
		pageBeforeBack:function(){
			$('#information_container').empty();
		}
	};
	//文章详情
	var tpl_information_content = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_information_content();  
		},
		pageBeforeBack:function(){
			
		}
	}
	//申请加盟
	var tpl_A_T_J = {
		pageShow: function(){
			bindFunction();
			pageFun.A_T_J();
		}
	};
	//报修
	var near_Repair = {
		pageBeforeShow:function(){
			var lng = fun.getCache("lng");
			var lat = fun.getCache("lat");
			var ace = fun.getCache('ace');
			Api.post(Api.maintainer_category,{},function(obj){
				var categoryhtml = '';
				$.each(obj.category,function(i,d){
					categoryhtml += '<div class="swiper-slide" cid="'+i+'">'+d+'</div>';
				});
				$('#Repair_wrapper').html(categoryhtml);
				$('#Repair_wrapper .swiper-slide').eq(0).addClass('swiper-slide-active-ck');
				var mySwiper1 = new Swiper('#RepairSlide_Nav',{
				  	freeMode : true,
					slidesPerView : 'auto',
					slidesPerView: 4,
		      		onClick: function(swiper){
		      			$('#Repair_wrapper .swiper-slide').removeClass('swiper-slide-active-ck');
						$('#Repair_wrapper .swiper-slide').eq(swiper.clickedIndex).addClass('swiper-slide-active-ck');
						var tid = $('#Repair_wrapper .swiper-slide.swiper-slide-active-ck').attr('cid');
						if(tid && tid > 0){
							pageFun.RepairGetListData(lat,lng,ace,tid);							
						}
						
					}
			  	});
			})
		},
		pageShow: function(){
			bindFunction();
			pageFun.Repair();
		}
	};
	
	//社区
	var community = { 
		pageShow: function() { 
			bindFunction();
			pageFun.Community(); 
			var deceleration = mui.os.ios?0.003:0.0009;
			$('.mui-scroll-wrapper').scroll({
					bounce: false,
					indicators: true, //是否显示滚动条
					deceleration:deceleration
			});
			$('.Community-tab .border-btm').click();
			
		}
	};
	
	//板块专区
	var tpl_bkl = {
		pageShow: function() {
			bindFunction();
			pageFun.bk();
		} 
	};
	//帖子详情
	var tpl_T_Z1 = {
		pageShow: function() {
			bindFunction();
			pageFun.T_Z1();
		}
	};
	
	//发帖
	var tpl_Post = {
		pageShow: function() {
			bindFunction();
			pageFun.Post();
		}
	};
	
	//商城首页
	var tpl_Mall_home = {
		pageShow: function() {
			bindFunction();
			$(".footer0").show();

		},
		pageBeforeShow:function(){
			$(".MallHome").css({"margin-top":$(".pHead").height(),'margin-bottom':$(".footer0").height()});
			$(".MallHome").height($(window).height()-$('.pHead').height()-$(".footer0").height());
			pageFun.Mall_home();
			
		}
	};
	//商城 
	var tpl_Shopping_Mall = {
		pageShow: function() {
			bindFunction();
			pageFun.Shopping_Mall();  
		}
	};
	//商品详情
	var tpl_Product_Details = {
		pageShow: function() {
			bindFunction(); 
			pageFun.Product_Details();
		},
		pageBeforeBack:function(){
			$('.PD_swiper,.PDMSwiper').empty();
		}
	};
	
	//设置
	var tpl_Set_Up ={
		pageShow: function() {
			bindFunction();
			pageFun.Set_Up();
		}
	};
	
	//关于我们
	var tpl_About_us = {
		pageShow: function() {
			bindFunction();
			pageFun.About_us();
		}
	};
	
	//软件介绍
	var tpl_About_us2 = {
		pageShow: function() {
			bindFunction();
			pageFun.About_us2();
		}
	};
	
	//客服留言 
	var tpl_Z_X_KF = {
		pageShow: function() {
			bindFunction();
			pageFun.Z_X_KF();
		}
	};
	//我的
	var tpl_My = {
		pageBeforeShow:function(){
			var token = fun.getCache('token');
		if(!token) {
			$("#my-name").text("");
			$("#my-qm").text("");
			$('.my_info_text').hide();
			$("#my-qm").find('.iconfont').removeClass('icon-shiliangzhinengduixiang9');
			$('#my-img').attr('src', 'images/t.jpg');
			$('#My-maintop li a i').css('background-color', '');
			$("#tpl_My .pBody").prepend("<div id='MyUserLogin' style='display:block;position:absolute;top:1rem;width:100%;z-index:1000;text-align:center;'><span style='color:#444;font-size:0.25rem;'>未登录 </span>&nbsp;<span style='color:#ff6700;font-size:0.25rem;'>立即登录</span></div>")
			$("#MyUserLogin").show();
			fun.bindOnce("#MyUserLogin span", 'tap', function() {
				$("#tpl_Land").addClass('popPageShow');
				pageFun.login();
			});
			fun.bindOnce('.My-main *,#tpl_My .pHead a,.My-maintop li,.my_fenxiang,.my_memberP', 'tap', function(event) {
				var token = fun.getCache('token');
				if(!token) {
					event.stopPropagation();
					$("#tpl_Land").addClass('popPageShow');
					pageFun.login();
					pageFun.ios_window("#ff5000", "UIStatusBarStyleBlackOpaque");
				}
			})
		}else{
			$('.my_info_text').show();
		}
			$('#tpl_My').css('z-index','66');
		},
		pageShow: function() {
			bindFunction();
			$(".footer0").show();
			$(".footer0 .footer li").removeClass("cur");
			$(".footer0 .footer li").eq(3).addClass('cur');
			pageFun.My();
			
		}
	};
	// 维修工申请
	var tpl_RepairApply = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_RepairApply();
		}
	}
	// 品牌入驻 
	var tpl_BrandSettled = {
		pageBeforeShow:function(){
			
		},
		pageShow: function() {
			bindFunction();
			pageFun.tpl_BrandSettled();
		}
	}
	
	//地址管理
	var tpl_Address = {
		pageShow: function() {
			bindFunction();
			pageFun.Address();
		}
	};
	
	//地址编辑 tpl_EditAddress
	var tpl_EditAddress = {
		pageShow: function() {
			bindFunction();
			pageFun.EditAddress();
		}
	};
	
	//添加地址 tpl_addressadd
	var tpl_addressadd = {
		pageShow: function() {
			bindFunction();
			pageFun.addressadd();
		}
	};
	
	//我的棋牌室
	var tpl_My_Chess1 = {
		pageShow: function() {
			bindFunction();
			pageFun.My_Chess1();
		}
	};
	
	//预约订单
	var tpl_Order2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Order2();
		}
	};
	
	//我的评价
	var tpl_My_evaluate ={
		pageShow: function(){
			bindFunction();
			pageFun.My_evaluate();
		}
	};
	
	//店铺维护
	var tpl_Maintain = {
		pageShow: function(){
			bindFunction();
			pageFun.Maintain();
		}
	};
	
	//预约订单
	var tpl_Order1 = {
		pageShow: function() {
			bindFunction();
			pageFun.Order1();
		}
	};
	
	//我的订单 
	var tpl_OrderDetails = {
		pageShow: function() {
			bindFunction();
			pageFun.OrderDetails();
		}
	};
	
	//待付款
	var tpl_FuKuan = {
		pageShow: function() {
			bindFunction();
			pageFun.FuKuan();
		}
	};
	
	//待发货
	var tpl_FaHuo = {
		pageShow: function() {
			bindFunction();
			pageFun.FaHuo();
		}
	};
	
	//待评价
	var tpl_YuYue = {
		pageShow: function() {
			bindFunction();
			pageFun.YuYue();
		}
	};
	
	//待收货
	var tpl_ShouHuo = {
		pageShow: function() {
			bindFunction();
			pageFun.ShouHuo();
		}
	};
	
	//评价 
	var tpl_Comment = {
		pageShow: function() {
			bindFunction();
			pageFun.Comment();
		}
	};
	
	//商品评价 
	var tpl_Comment2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Comment2();
		}
	};
	//我的订单
	var tpl_My_Order = {
		pageShow: function() {
			bindFunction();
			pageFun.My_Order();
		}
	};
	//个人信息
	var tpl_Personal = {
		pageShow: function() {
			bindFunction();
			pageFun.Personal();
			pageFun.user();
		}
	};
	
	//申请入驻 
	var tpl_Settled = {
		pageShow: function() {
			bindFunction();
			pageFun.Settled();
		}
	};
	
	// 附近麻将机店 入驻 
	var tpl_Settled2 = {
		pageShow: function() {
			bindFunction();
			pageFun.Settled2();
		}
	};
	
	//联系人
	var tpl_Contacts = {
		pageShow: function() {
			bindFunction();
			pageFun.Contacts();
		}
	};

	//发送消息 单聊 
	var tpl_FS_XX = {
		pageShow: function() {
			bindFunction();
			pageFun.FS_XX();
		}
	};
	
	//发送消息 群聊 
	var tpl_Group_chat = {
		pageShow: function() {
			bindFunction();
			pageFun.Group_text();
		},
		pageBeforeBack: function(){
			$('#main').html("");
		}
	};
	
	//群聊邀请 
	var tpl_GroupChat = {
		pageBeforeShow:function(){
			$("#ChatContant").hide();
		},
		pageShow: function() {
			bindFunction();
			pageFun.GroupChat();
		}
	};
	//群资料
	var tpl_Chat = {
		pageBeforeShow:function(){
			$("#ChatContant").show();
			$("#Chat_main").css("margin-top",$('#ChatContant').height());
		},
		pageShow: function() {
			bindFunction();
			pageFun.Chat();
		},
		pageBeforeBack: function(){
			$("#ChatContant").hide();
			$("#Add_this").empty();
		}
	};
	
	//群管理 
	var tpl_qun = {
		pageShow: function() {
			bindFunction();
			pageFun.qun();
		}
	};
	
	//群组 
	var tpl_Group = {
		pageShow: function() {
			bindFunction();
			pageFun.Group();
		}
	};
	//添加好友
	var tpl_ADD = {
		pageShow: function() {
			bindFunction();
			pageFun.ADD();
		}
	};
	
	//搜索群组
	var tpl_ADD_Group = {
		pageShow:function(){
			bindFunction();
			pageFun.ADD_Group();
		}
	};
	
	//创建群组
	var tpl_CreateGroup = {
		pageBeforeShow:function(){
			$("#CreateGroup_name .content").text("");
			$(".xuzhi textarea").val("");
			$("#CreateGroup_header").hide();
		},
		pageShow:function(){
			bindFunction();
			pageFun.CreateGroup();
		}
	};
	//消息
	var tpl_My_news = {
		pageShow: function() {
			bindFunction();
			pageFun.My_news();
		}
	}
	
	//购物车
	var Shopping_Cart_page  = {
		pageShow: function() {
			bindFunction();
			pageFun.Shopping_Cart(); 
		}
	};
	
	//确认订单
	var tpl_Confirm_Order = {
		pageShow: function() {
			bindFunction(); 
			pageFun.Confirm_Order(); 
		},
		pageBeforeBack:function(){
			viewApi.parms = []; 
		}
	};
	
	//web视图窗口
	var tpl_webview = {
		pageShow: function() {
			bindFunction();
			pageFun.webview(); 
		}
	};
	
	// 生成地图 
	var tpl_gpsmap = {
		pageShow: function() {
			bindFunction();
			pageFun.gpsmap(); 
		}
	};
	mui.init({
		gestureConfig:{
//			tap: true, //默认为true
//			doubletap: false, //默认为false   双击
//			longtap: false, //默认为false 重击
			swipe: false, //默认为true  
//			drag: false, //默认为true
//			hold:false,//默认为false，不监听
//			release:false//默认为false，不监听  释放
			hold:true,
			longtap:true
		},
	    swipeBack:false //关闭-右滑关闭功能  
	});  
 	var viewApi = mui('#app').view({
		defaultPage: '#home'
	});
	var view = viewApi.view;
	var first = 0;
	(function(M) {
		
		var touchStart_x = null,touchStart_y = null,touchMove_x = null,touchMove_y = null,boxStartX=null,boxStartY=null;
		var tmpbtn = document.getElementById('tmpbtn');
		var _h = tmpbtn.offsetHeight;
		var _w = tmpbtn.offsetWidth;
		var window_h = window.screen.height;
		var window_w = window.screen.width;
		
		tmpbtn.ontouchstart = function(e){
			touchStart_x = e.targetTouches[0].pageX;
	        touchStart_y = e.targetTouches[0].pageY;
	        boxStartX = tmpbtn.getBoundingClientRect().left;
	        boxStartY = tmpbtn.getBoundingClientRect().top;
		}
		tmpbtn.ontouchmove = function(e){
			touchMove_x = e.targetTouches[0].pageX-touchStart_x;
	        touchMove_y = e.targetTouches[0].pageY-touchStart_y;
	        var _x = boxStartX + touchMove_x;
	        var _y = boxStartY + touchMove_y;
	        if(_x <= 0 ){ _x = 0; }
	        if(_y<=0){ _y=0; }
	        if(_x>=window_w-_w){ _x = window_w - _w; }
	        if(_y>=window_h-_h){ _y = window_h - _h; }
	        tmpbtn.style.left = _x + 'px';
	        tmpbtn.style.top = _y + 'px';
		}
		
		$('#tmpbtn').click(function(){
			if(window.talk){				
				pageFun.closeTalk();
			}else{
				pageFun.showTalk();
			}
		});
		$("#tpm_head span").click(function(){
			pageFun.closeTalk();
		})
		//处理view的后退与webview后退
		var oldBack = M.back;
		M.back = function() {
			var ClickPage	= '-tpl_My-home\n-tpl_BeautyLive-tpl_Mall_home-Shopping_Cart_page-tpl_Admission';
			//如果有弹出页面则先关闭弹出页面
			if($('.popPageShow').length>0){
				$('.popPageShow').removeClass('popPageShow');
			}else if(ClickPage.indexOf(view.currentPageId)>0){
				if (!first) {
	                first = new Date().getTime();
	                mui.toast('再按一次退出应用');
	                setTimeout(function() {
	                    first = null;
	                }, 1000);
	            } else {	            	
	                if (new Date().getTime() - first < 2000) {
	                    plus.runtime.quit();
	                }
	            }
				return false;
			}else if(window.embed){
				window.embed.close();
				viewApi.back();
				window.embed=null;
			}else if (viewApi.canBack()) { //如果view可以后退，则执行view的后退
				viewApi.back();
			}else { //执行webview后退
				oldBack();
			}
		};
		M.back2 =M.back;
		
		//注册页面显示的回调函数
		var viewCallBacks = ['pageBeforeShow','pageShow','pageBeforeBack','pageBack'];
		$.each(viewCallBacks, function(i,callback) {
			view.addEventListener(callback, function(e) {
				var fn = null;
				var cmd = ' fn = ' + e.detail.page.id+'.'+callback;
//				if('pageShow'==callback){
//					setTimeout(function(){
//						eval( cmd );
//						if(typeof(fn) == 'function'){ fn();}
//					},200);
//				}else{
					eval( cmd );
					if(typeof(fn) == 'function'){ fn();}
//				} 
				view.currentPageId = e.detail.page.id;//如果点两次退出   调用此   currentPageID
				
				console.log(e.detail.page.id + ' '+callback);
				console.log('[Parm]：'+viewApi.parms);
			});
		});
		pageFun.initPage();
	})(mui);
	Api.post(Api.app_open_ad,{},function(obj){
		if(obj.s){
			$('.HomeGuangGao .content').css('background-image','url('+obj.ad.img+')');
			$('.HomeGuangGao .content').attr('t_url',obj.ad.url);
			Guanggao();
		}
	});
	function Guanggao(){
		$('.HomeGuangGao .content').unbind('tap').on('tap',function(){
			var url = $(this).attr('t_url');
			$('.HomeGuangGao').fadeOut();
			viewApi.go('#tpl_webview',fun.base64encode(url));
		});
		if(GuangGaoSta){
			GuangGaoSta = false;
			$('.HomeGuangGao').show();
			var GuangNumber = 3;
			var GuangSta = setInterval(function(){
				GuangNumber--;
				$('.HomeGuangGao .btn').text('跳过'+GuangNumber+'s');
				if(GuangNumber <= 0){
					clearInterval(GuangSta);
					$('.HomeGuangGao').fadeOut();
				}
			},1000);
			$('.HomeGuangGao .btn').unbind('tap').on('tap',function(){
				clearInterval(GuangSta);
				$('.HomeGuangGao').fadeOut();
			})
		}
	}
//	viewApi.go('#tpl_webview',fun.base64encode(Zurl));
	home.pageShow();
	clearBug();
/***
 * 初始化全局的事件绑定
 */
function bindFunction() {
	pageFun.onepage();
	//进入隐藏
	var pageID = view.currentPageId;	
	if(pageID != 'home' && pageID != 'tpl_shopPart' && pageID != 'Shopping_Cart_page' && pageID != 'tpl_BeautyLive' && pageID != 'tpl_My'){	
//		console.log("其他页面");
		$(".footer0,.footer9,.G_W_C_Eject,.rgba,.rgba2,.update,.bk,.C_O_E,.Age,.GX,.Gender,#My-Maintain,#SR_input,.android-ics,.tan3,#bq,#MyUserLogin").hide();
	}else{
		$('.footer0').show();
		$(".footer9,.G_W_C_Eject,.rgba,.rgba2,.update,.bk,.C_O_E,.Age,.GX,.Gender,#My-Maintain,#SR_input,.android-ics,.tan3,#bq,#MyUserLogin").hide();
	}
	 
	$(".footer0 a").bind('click',function(ev){
		$('#mk').fadeIn();
		$('.footer0 li.cur').removeClass('cur');
		$(this).parents('li').addClass('cur');
		setTimeout(function(){ $('#mk').fadeOut(); },80);
	});
	
	
	
	//进入页面跳转最上
	$('body').scrollTop(0);
	
	pageFun.ios_window('#fff','UIStatusBarStyleDefault')
	$(".footer9 a,.footer0 a").click(function(){
		//$(".footer9 a,.footer0 a").css("color","#000");
		//$(this).css("color","#ff5000");
	});
//	$(".footer li a p").css("color","#000");
//	$(".footer9 li a p").css("color","#000");
	fun.bindOnce('.icon-zuojiantou','tap',function(){
		viewApi.back();		
	})
//	$("header .icon-zuojiantou").unbind('click').click(function(){
//		history.go(-1);
//		window.history.back();
//	});
	//弹出隐藏
	$(".icon-guanbi,.rgba").click(function(){
		$(".Eject").hide();
	});
	
	//删除上传图片按钮
	$(".remove").click(function(){
		$(this).parent(".tu").remove();
	});

	//滑块效果
	$(".btn2").click(function(){
		if($(this).hasClass("left")){
			$(this).removeClass("left");
			$(this).addClass("right");
			$(this).parent(".SetUp-btn").css("background-color","#FF5000")
		}else{
			$(this).removeClass("right");
			$(this).addClass("left");
			$(this).parent(".SetUp-btn").css("background-color","#bbb")
		}
	});
	//个人心中js
	$(".li3").click(function(){
		$(".Gender,.PersonalRGBA").show();
	});
	$(".Gender ul li input").click(function(){
		$("input").removeClass("input2");
		$(this).addClass("input2");
	});
	$(".qx").click(function(){
		$(this).parents(".G_fixed").hide();
		$(".PersonalRGBA").hide();
	});
	$(".li4").click(function(){
		$(".GX,.PersonalRGBA").show();
		pageFun.user();
		$('.GX textarea').text(Y.sig);
	});

	$(".age_x").click(function(){
		$(".Age,.PersonalRGBA").hide();
	});

    //tab切换
    $(".S_M_M_header li").click(function(){
		$(".S_M_M_header li").removeClass("border-btm");
		$(this).addClass("border-btm");
	});
}

/***
 * 处理输入框被弹出键盘遮挡的问题
 */
function clearBug() {
	if(/Android/gi.test(navigator.userAgent)) {
		window.addEventListener('resize', function() {
			if(document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
				window.setTimeout(function() {
					document.activeElement.scrollIntoViewIfNeeded();
				}, 0);
			}
		})
	}
}